define(['egis'], function (egis) {
    Window.deserializer = Window.deserializer || new egis.core.Deserializer();
    Window.container = Window.container || {};
    var toolTips = toolTips || [];
    dsBridge.register('create_CoordinateTransform', function (sourceId, mapId) {
        var coordinateTransform = new egis.sfs.CoordinateTransform();
        Window.container[sourceId] = coordinateTransform;
    })

    dsBridge.register('CoordinateTransform_transform', function (sourceId, geometry, srid) {
        try{
            geometry = Window.deserializer.createJsInstance(JSON.parse(geometry));
            var source = Window.container[sourceId];
            return source.transform(geometry, srid);
        }
        catch (e){
            alert(e)
        }
    })

    dsBridge.register('TooltipWare_remove', function (sourceId, tooltipId) {
        var source = Window.container[sourceId];
        var tooltip = Window.container[tooltipId];
        source.remove(tooltipId);
        var index = toolTips.index(tooltip);
        if(index >= 0){
            toolTips.splice(index, 1);
        }
        delete Window.container[tooltipId];
        tooltip = null;
    })

    dsBridge.register('TooltipWare_clear', function (sourceId) {
        var source = Window.container[sourceId];
        source.clear();
        toolTips.forEach(function (toolTip) {
            delete Window.container[toolTip.id];
            tooltip = null;
        })
    })
})